package com.tc.data.test.service.impl;

import com.tc.data.common.annotation.RepositorySharding;
import com.tc.data.test.entity.Tc;
import com.tc.data.test.entity.TcExample;
import com.tc.data.test.repository.TcMapper;
import com.tc.data.test.service.TcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TcServiceImpl implements TcService {

    @Autowired
    private TcMapper tcMapper;

    @Override
    @RepositorySharding(strategy = "repositoryShardingStategyById", key = "#shard")
    public List<Tc> findAll(String shard) {
        TcExample tcExample = new TcExample();
        tcExample.createCriteria();
        return tcMapper.selectByExample(tcExample);
    }

    @Override
    @RepositorySharding(strategy = "repositoryShardingStategyById", key = "#shard")
    public List<Tc> findAllBySplitTable(String shard) {
        TcExample tcExample = new TcExample();
        tcExample.createCriteria();
        return tcMapper.selectByTableName("1");//查询分表
    }

}
